package com.global.emc.spring.method.support.chain.command;

import com.global.emc.core.exception.impl.ValidationEMCException;
import com.global.emc.spring.method.support.chain.BeforeCallMethodContent;

/**   
 *  
 * @Description:  [抽象Command提供获取对象值的方法]   
 * @Author:       [Joly_Huang]   
 * @CreateDate:   [2014年2月24日 下午4:59:51]   
 * @UpdateUser:   [Joly_Huang]   
 * @UpdateDate:   [2014年2月24日 下午4:59:51]   
 * @UpdateRemark: [说明本次修改内容]  
 * @Version:      [v1.0] 
 *    
 */
public abstract class AbstractBeforeCallMethodCommand implements BeforeCallMethodCommand{

	@SuppressWarnings("unchecked")
	public <T> T findObject(BeforeCallMethodContent content,Class<T> target)throws ValidationEMCException{
		for(Object obj : content.getAobj()){
			if(target.isInstance(obj)){
				return (T)obj;
			}
		}
		
		throw new ValidationEMCException(new StringBuilder(target.getSimpleName()).append(" is not find").toString());
	}
	
}
